<%--
  Created by IntelliJ IDEA.
  User: 陌·笙
  Date: 2019-01-12
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>退货审核</title>
    <jsp:include page="/comm/tag.jsp"></jsp:include>
    <script>
        $(function () {
            $("#detail").bootstrapTable({
                url:"/tuihuo/showTuiHou",
                height:750,
                pageSize:25,
                pageNumber:1,
                //启用分页，但是默认情况下，是客户端分页的
                pagination:true,
                sidePagination:'server',
                queryParams:function(params){
                    var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        limit: params.limit,  //页面大小
                        offset: params.offset, //页码
                        seat:$("[name='seat']").val(),
                        th:'未审核',
                    };
                    return temp;
                },
                locale:'zh-CN',//中文支持,
                toolbar:'#top',
                columns:[
                    {field:"seat",title:"单号",align:"center"},
                    {field:"repertory.repertoryName",title:"商品名称",align:"center"},
                    {field:"repertory.model",title:"手机类型",align:"center"},
                    {field:"repertory.repertoryColor",title:"颜色",align:"center"},
                    {field:"repertory.presetPrice",title:"单价",align:"center"},
                    {field:"totalPrice",title:"总价格",align:"center"},
                    {field:"th",title:"状态",align:"center"},
                    {field:"retreatTime",title:"退货时间",align:"center"},
                    {field:"retreatNum",title:"退货数量",align:"center"},
                    {field:"retreatRemark",title:"备注",align:"center"},
                    {
                        title:"审核",
                        align:"center",
                        formatter:function(value,row,index){
                            return " <button class=\"btn btn-danger\" onclick=\"up('"+index+"')\" >审核</button>"
                        }
                    },
                ]
            })
        })
        function up(index) {
            if($("[name='tableId']").val()!=""){
                $("#detail").bootstrapTable("uncheck",$("[name='tableId']").val());
            }
            $("#detail").bootstrapTable("check",index);//根据索引让该行选中
            var a=$("#detail").bootstrapTable("getSelections")[0];
            $("[name='reteeatid']").val(a.reteeatid);
            $("[name='tableId']").val(index);
            $("#shenhe").modal('show');
        }
        function cha(){
            var opts = $("#detail").bootstrapTable("getOptions");
            var seat=$("[name='seat']").val();
            var repertoryName=$("[name='repertoryName']").val();
            var limit = opts.pageSize;
            var offset = (opts.pageNumber-1) * limit;
            $.ajax({
                url:"/tuihuo/showTuiHou",
                type:"get",
                data:{"seat":seat,"repertoryName":repertoryName,"th":"未审核",'limit':limit,'offset':offset},
                success:function(data){
                    $("#detail").bootstrapTable("load",data);
                }
            })
        }
    </script>
    <style>
        fieldset {
            color: #333;
            border: #52915e solid 1px;
            padding: 10px;
        }
        legend{
            width: 80px;
            border-bottom: 0px;
        }
    </style>
</head>
<body>
<div style="margin-left: 50px;margin-right: 50px">
    <div class="#top" style="margin-top: 30px">
        <div class="col-md-12">
            <form action="" method="post" role="form" class="form-horizontal">

                <div class="col-md-1 pull-right">
                    <button type="button" class="btn btn-primary btn-info glyphicon glyphicon-search" onclick="cha()">查询</button>
                </div>
                <div class="form-group col-md-4 pull-right">
                    <label for="" class="col-md-4 control-label">商品名称:</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control" name="repertoryName" placeholder="可模糊查询">
                    </div>
                </div>
                <div class="form-group col-md-4 pull-right">
                    <label for="" class="col-md-4 control-label">单号查询:</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control" name="seat" placeholder="可模糊查询">
                    </div>
                </div>
            </form>
        </div><%--搜索框--%>
    </div>
<table id="detail" class="table-striped"></table>
    <div class="modal fade" id="shenhe">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">审核</h4>
                </div>
                <div class="modal-body">
                    <fieldset>
                        <legend style="font-size: 13px">
                            设置退货状态
                        </legend>
                        <center>
                            <input type="radio" name="save" value="2" checked="checked"><label for="rbpass">批准</label>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="save" value="1"><label for="rbunpass">拒批</label>
                            <input type="hidden" name="reteeatid">
                            <input type="hidden" name="tableId">
                        </center>

                    </fieldset>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" onclick="smts()" class="btn btn-primary">保存</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>
<script>
    function smts() {
        var reteeatid=$("[name='reteeatid']").val();
        var seat=$("[name='seat']").val();
        var repertoryName=$("[name='repertoryName']").val();
        var save=$("[name='save']:checked").val();
        var opts = $("#detail").bootstrapTable("getOptions");
        var limit = opts.pageSize;
        var offset = (opts.pageNumber-1) * limit;
        $.ajax({
            url:"/tuihuo/upTuiHou",
            type:"get",
            data:{"Reteeatid":reteeatid,"save":save,"seat":seat,"repertoryName":repertoryName,"th":"未审核",'limit':limit,'offset':offset},
            success:function(data){
                $("#detail").bootstrapTable("load",data);
                $("#shenhe").modal('hide');
                swal("审核成功！", "您已经审核了这条单号", "success");
            }
        })
    }
</script>
</body>
</html>
